Skip to content

Delay variable coercion until argument use#688

Draft
vladar wants to merge 4 commits into
mainfrom
vladar/lazy-variable-coercion
Draft

Delay variable coercion until argument use#688
vladar wants to merge 4 commits into
mainfrom
vladar/lazy-variable-coercion

Conversation

@vladar

@vladar vladar commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Input object variable definitions can reference types that are not present in the initial browser-side schema fragment. Eagerly coercing all variables during execution context creation forces those input definitions to be loaded too early.

This changes Supermassive execution to keep raw variable inputs in the execution context and coerce variables lazily when an argument value actually references them, using the schema fragment available at that call site. Coercion results are cached per variable so repeated uses do not re-run scalar parsing or input coercion.

Characterization tests cover loading the root mutation fragment before coercing an input variable, avoiding schema loads for unused input variable definitions, and ensuring a variable used multiple times is coerced only once.

Validation:

  • packages/supermassive typecheck
  • yarn workspace @graphitation/supermassive test --runInBand --diagnostics=false
  • yarn workspace @graphitation/supermassive lint

vrazuvaev and others added 4 commits July 9, 2026 18:09
Coerce GraphQL variables lazily against the schema fragment available at the field argument call site, and cache each variable result so repeated usages do not re-coerce.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Route getVariableValues through the lazy per-variable coercion path so eager and late coercion cannot diverge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the root-fragment/input-variable characterization while removing unrelated union output schema from the test fixture.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant